<?php
namespace App\Admin\Extensions\Tools;

use Encore\Admin\Admin;
use Encore\Admin\Grid\Tools\AbstractTool;
class InStorage extends AbstractTool
{
    protected function script()
    {
        $url = url(\Request::path().'/InStorage');
		$csrf_field = csrf_field();

        return <<<EOT
$('.bulid-news').on('click', function() {
	layer.load();
    var id = selectedRows().join();

    $.ajax({
        method: 'post',
        url: '$url',
        data: {
            _token: LA.token,
			id: id
        },
        success: function (data) {
            $.pjax.reload('#pjax-container');
			layer.closeAll('loading');
            if (typeof data === 'object') {
                if (data.status == 1) {
                    swal(data.message, '', 'success');
                } else {
                    swal(data.message, '', 'error');
                }
            }
        }
    });
    
});
EOT;
    }

    public function render()
    {
        Admin::script($this->script());
		$message = '入库';

        return view('admin.tools.build', compact('message'));
    }
}